package pageobjectpattern;

import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;

public class CartPage extends Page{
	
	private String buyButtonPath = "//*[@name='Buy']";//"/html/body/div/form/input"
	private String boughtInformationPath = "/html/body/div/p[2]";
	private String goBackPath = "/html/body/a";
	public static final String ADRESS = "localhost:8084/MyWeb1/koszyk.jsp";
	
	public CartPage(WebDriver driver) {
		super(driver);
		// TODO Auto-generated constructor stub
	}
	
	public boolean isOpen() {
        try{
        	findElementByLinkText("Back to Catalog");               		
        } catch(NoSuchElementException e){
                return false;
        }
        return true;
	}
	
	public void clickBuy() {
    	clickXPath(buyButtonPath);
    }
	
	public void clickGoBack() {
    	clickXPath(goBackPath);
    }
	
	public boolean isItemBought() {
        try{
        	findElement(boughtInformationPath);               		
        } catch(NoSuchElementException e){
                return false;
        }
        return true;
	}

}
